# -*- coding: utf-8 -*- 
# import '大盘' data in 'dapan.txt' to database
import os
from time import time
from sqlalchemy import *

def pline(line):
    l = line.strip().split('\t')
    return {'date':l[0], 'open':l[1], 'high':l[2], 
            'low':l[3],'close':l[4],'volume':l[5]}

db = create_engine('sqlite:///stocks.db')
metadata = BoundMetaData(db)
dps_table = Table('dps', metadata, autoload=True)

f = 'dp.txt'

dp = []
for l in open(f).readlines()[1:]:
    r = pline(l)
    dp.append(r)

#print dp
dps_table.insert().execute(dp)
